package com.czm.art_light.controller;

import com.czm.art_light.constant.ApiRouterConsts;
import com.czm.art_light.constant.ArtErrorCodeEnum;
import com.czm.art_light.entity.ArtCategory;
import com.czm.art_light.param.request.ArtInfoReqDto;
import com.czm.art_light.param.request.PageReqDto;
import com.czm.art_light.param.response.ArtCategoryBasicInfoRespDto;
import com.czm.art_light.param.response.ArtInfoRespDto;
import com.czm.art_light.param.response.RestResp;
import com.czm.art_light.service.ArtCategoryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 类别信息 API 控制器
 */
@Tag(name = "类别管理", description = "类别相关接口")
@RestController
@RequestMapping(ApiRouterConsts.CATEGORY_API_URL_PREFIX)
public class ArtCategoryController {
    @Autowired
    private ArtCategoryService artCategoryService;

    /**
     * 获取类别信息 根据id以及分页的信息
     */
    @Operation(summary = "获取类别信息", description = "根据id以及分页的信息")
    @PostMapping("/getArtCategoryById")
    public RestResp<ArtInfoRespDto> getArtCategoryById(@Valid @RequestBody ArtInfoReqDto artInfoReqDto) {
        return RestResp.ok(artCategoryService.getById(artInfoReqDto));
    }

    /**
     * 获取所有的类别基本信息
     */
    @Operation(summary = "获取所有的类别基本信息")
    @PostMapping("/getAllArtCategories")
    public RestResp<List<ArtCategoryBasicInfoRespDto>> getAllArtCategories(@RequestBody PageReqDto pageReqDto) {
        List<ArtCategoryBasicInfoRespDto> artCategories = artCategoryService.list(pageReqDto);
        return RestResp.ok(artCategories);
    }

}
